<?php
/*
	This SQL query will create the table to store your object.

	CREATE TABLE `questpage` (
	`questpageid` int(11) NOT NULL auto_increment,
	`level` VARCHAR(255) NOT NULL,
	`race` VARCHAR(255) NOT NULL,
	`npc` VARCHAR(255) NOT NULL,
	`island` VARCHAR(255) NOT NULL,
	`town` VARCHAR(255) NOT NULL,
	`area` VARCHAR(255) NOT NULL,
	`field` VARCHAR(255) NOT NULL,
	`dung` VARCHAR(255) NOT NULL,
	`obj` LONGTEXT NOT NULL,
	`exp` VARCHAR(255) NOT NULL,
	`jp` VARCHAR(255) NOT NULL,
	`r` VARCHAR(255) NOT NULL,
	`p` VARCHAR(255) NOT NULL,
	`basic` VARCHAR(255) NOT NULL,
	`choice` LONGTEXT NOT NULL,
	`bonus` VARCHAR(255) NOT NULL,
	`prev` VARCHAR(255) NOT NULL,
	`next` VARCHAR(255) NOT NULL,
	`intro` LONGTEXT NOT NULL,
	`object` LONGTEXT NOT NULL,
	`walk` LONGTEXT NOT NULL,
	`con` LONGTEXT NOT NULL,
	`misc` LONGTEXT NOT NULL,
	`levelvalue` INT NOT NULL,
	`expvalue` INT NOT NULL,
	`jpvalue` INT NOT NULL,
	`rvalue` INT NOT NULL,
	`pvalue` INT NOT NULL,
	`name` VARCHAR(255) NOT NULL,
	`content` TEXT NOT NULL,
	`revid` INT NOT NULL, PRIMARY KEY  (`questpageid`)) ENGINE=MyISAM;
*/

/**
* <b>Questpage</b> class with integrated CRUD methods.
* @author Php Object Generator
* @version POG 3.0f / PHP5.1 MYSQL
* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql
* @copyright Free for personal & commercial use. (Offered under the BSD license)
* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pdo&pdoDriver=mysql&objectName=Questpage&attributeList=array+%28%0A++0+%3D%3E+%27level%27%2C%0A++1+%3D%3E+%27race%27%2C%0A++2+%3D%3E+%27npc%27%2C%0A++3+%3D%3E+%27island%27%2C%0A++4+%3D%3E+%27town%27%2C%0A++5+%3D%3E+%27area%27%2C%0A++6+%3D%3E+%27field%27%2C%0A++7+%3D%3E+%27dung%27%2C%0A++8+%3D%3E+%27obj%27%2C%0A++9+%3D%3E+%27exp%27%2C%0A++10+%3D%3E+%27jp%27%2C%0A++11+%3D%3E+%27r%27%2C%0A++12+%3D%3E+%27p%27%2C%0A++13+%3D%3E+%27basic%27%2C%0A++14+%3D%3E+%27choice%27%2C%0A++15+%3D%3E+%27bonus%27%2C%0A++16+%3D%3E+%27prev%27%2C%0A++17+%3D%3E+%27next%27%2C%0A++18+%3D%3E+%27intro%27%2C%0A++19+%3D%3E+%27object%27%2C%0A++20+%3D%3E+%27walk%27%2C%0A++21+%3D%3E+%27con%27%2C%0A++22+%3D%3E+%27misc%27%2C%0A++23+%3D%3E+%27levelvalue%27%2C%0A++24+%3D%3E+%27expvalue%27%2C%0A++25+%3D%3E+%27jpvalue%27%2C%0A++26+%3D%3E+%27rvalue%27%2C%0A++27+%3D%3E+%27pvalue%27%2C%0A++28+%3D%3E+%27name%27%2C%0A++29+%3D%3E+%27content%27%2C%0A++30+%3D%3E+%27revid%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B4%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B5%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B6%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B7%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B8%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B9%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B10%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B11%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B12%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B13%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B14%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B15%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B16%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B17%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B18%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B19%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B20%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B21%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B22%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B23%2B%253D%253E%2B%2527INT%2527%252C%250A%2B%2B24%2B%253D%253E%2B%2527INT%2527%252C%250A%2B%2B25%2B%253D%253E%2B%2527INT%2527%252C%250A%2B%2B26%2B%253D%253E%2B%2527INT%2527%252C%250A%2B%2B27%2B%253D%253E%2B%2527INT%2527%252C%250A%2B%2B28%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B29%2B%253D%253E%2B%2527TEXT%2527%252C%250A%2B%2B30%2B%253D%253E%2B%2527INT%2527%252C%250A%2529
*/
include_once('class.pog_base.php');
class Questpage extends POG_Base
{
	public $questpageId = '';

	/**
	 * @var VARCHAR(255)
	 */
	public $level;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $race;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $npc;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $island;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $town;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $area;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $field;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $dung;
	
	/**
	 * @var LONGTEXT
	 */
	public $obj;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $exp;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $jp;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $r;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $p;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $basic;
	
	/**
	 * @var LONGTEXT
	 */
	public $choice;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $bonus;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $prev;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $next;
	
	/**
	 * @var LONGTEXT
	 */
	public $intro;
	
	/**
	 * @var LONGTEXT
	 */
	public $object;
	
	/**
	 * @var LONGTEXT
	 */
	public $walk;
	
	/**
	 * @var LONGTEXT
	 */
	public $con;
	
	/**
	 * @var LONGTEXT
	 */
	public $misc;
	
	/**
	 * @var INT
	 */
	public $levelvalue;
	
	/**
	 * @var INT
	 */
	public $expvalue;
	
	/**
	 * @var INT
	 */
	public $jpvalue;
	
	/**
	 * @var INT
	 */
	public $rvalue;
	
	/**
	 * @var INT
	 */
	public $pvalue;
	
	/**
	 * @var VARCHAR(255)
	 */
	public $name;
	
	/**
	 * @var TEXT
	 */
	public $content;
	
	/**
	 * @var INT
	 */
	public $revid;
	
	public $pog_attribute_type = array(
		"questpageId" => array('db_attributes' => array("NUMERIC", "INT")),
		"level" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"race" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"npc" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"island" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"town" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"area" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"field" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"dung" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"obj" => array('db_attributes' => array("TEXT", "LONGTEXT")),
		"exp" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"jp" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"r" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"p" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"basic" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"choice" => array('db_attributes' => array("TEXT", "LONGTEXT")),
		"bonus" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"prev" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"next" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"intro" => array('db_attributes' => array("TEXT", "LONGTEXT")),
		"object" => array('db_attributes' => array("TEXT", "LONGTEXT")),
		"walk" => array('db_attributes' => array("TEXT", "LONGTEXT")),
		"con" => array('db_attributes' => array("TEXT", "LONGTEXT")),
		"misc" => array('db_attributes' => array("TEXT", "LONGTEXT")),
		"levelvalue" => array('db_attributes' => array("NUMERIC", "INT")),
		"expvalue" => array('db_attributes' => array("NUMERIC", "INT")),
		"jpvalue" => array('db_attributes' => array("NUMERIC", "INT")),
		"rvalue" => array('db_attributes' => array("NUMERIC", "INT")),
		"pvalue" => array('db_attributes' => array("NUMERIC", "INT")),
		"name" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
		"content" => array('db_attributes' => array("TEXT", "TEXT")),
		"revid" => array('db_attributes' => array("NUMERIC", "INT")),
		);
	public $pog_query;
	
	
	/**
	* Getter for some private attributes
	* @return mixed $attribute
	*/
	public function __get($attribute)
	{
		if (isset($this->{"_".$attribute}))
		{
			return $this->{"_".$attribute};
		}
		else
		{
			return false;
		}
	}
	
	function Questpage($level='', $race='', $npc='', $island='', $town='', $area='', $field='', $dung='', $obj='', $exp='', $jp='', $r='', $p='', $basic='', $choice='', $bonus='', $prev='', $next='', $intro='', $object='', $walk='', $con='', $misc='', $levelvalue='', $expvalue='', $jpvalue='', $rvalue='', $pvalue='', $name='', $content='', $revid='')
	{
		$this->level = $level;
		$this->race = $race;
		$this->npc = $npc;
		$this->island = $island;
		$this->town = $town;
		$this->area = $area;
		$this->field = $field;
		$this->dung = $dung;
		$this->obj = $obj;
		$this->exp = $exp;
		$this->jp = $jp;
		$this->r = $r;
		$this->p = $p;
		$this->basic = $basic;
		$this->choice = $choice;
		$this->bonus = $bonus;
		$this->prev = $prev;
		$this->next = $next;
		$this->intro = $intro;
		$this->object = $object;
		$this->walk = $walk;
		$this->con = $con;
		$this->misc = $misc;
		$this->levelvalue = $levelvalue;
		$this->expvalue = $expvalue;
		$this->jpvalue = $jpvalue;
		$this->rvalue = $rvalue;
		$this->pvalue = $pvalue;
		$this->name = $name;
		$this->content = $content;
		$this->revid = $revid;
	}
	
	
	/**
	* Gets object from database
	* @param integer $questpageId 
	* @return object $Questpage
	*/
	function Get($questpageId)
	{
		$connection = Database::Connect();
		$this->pog_query = "select * from `questpage` where `questpageid`='".intval($questpageId)."' LIMIT 1";
		$cursor = Database::Reader($this->pog_query, $connection);
		while ($row = Database::Read($cursor))
		{
			$this->questpageId = $row['questpageid'];
			$this->level = $this->Unescape($row['level']);
			$this->race = $this->Unescape($row['race']);
			$this->npc = $this->Unescape($row['npc']);
			$this->island = $this->Unescape($row['island']);
			$this->town = $this->Unescape($row['town']);
			$this->area = $this->Unescape($row['area']);
			$this->field = $this->Unescape($row['field']);
			$this->dung = $this->Unescape($row['dung']);
			$this->obj = $this->Unescape($row['obj']);
			$this->exp = $this->Unescape($row['exp']);
			$this->jp = $this->Unescape($row['jp']);
			$this->r = $this->Unescape($row['r']);
			$this->p = $this->Unescape($row['p']);
			$this->basic = $this->Unescape($row['basic']);
			$this->choice = $this->Unescape($row['choice']);
			$this->bonus = $this->Unescape($row['bonus']);
			$this->prev = $this->Unescape($row['prev']);
			$this->next = $this->Unescape($row['next']);
			$this->intro = $this->Unescape($row['intro']);
			$this->object = $this->Unescape($row['object']);
			$this->walk = $this->Unescape($row['walk']);
			$this->con = $this->Unescape($row['con']);
			$this->misc = $this->Unescape($row['misc']);
			$this->levelvalue = $this->Unescape($row['levelvalue']);
			$this->expvalue = $this->Unescape($row['expvalue']);
			$this->jpvalue = $this->Unescape($row['jpvalue']);
			$this->rvalue = $this->Unescape($row['rvalue']);
			$this->pvalue = $this->Unescape($row['pvalue']);
			$this->name = $this->Unescape($row['name']);
			$this->content = $this->Unescape($row['content']);
			$this->revid = $this->Unescape($row['revid']);
		}
		return $this;
	}
	
	
	/**
	* Returns a sorted array of objects that match given conditions
	* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
	* @param string $sortBy 
	* @param boolean $ascending 
	* @param int limit 
	* @return array $questpageList
	*/
	function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
	{
		$connection = Database::Connect();
		$sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
		$this->pog_query = "select * from `questpage` ";
		$questpageList = Array();
		if (sizeof($fcv_array) > 0)
		{
			$this->pog_query .= " where ";
			for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
			{
				if (sizeof($fcv_array[$i]) == 1)
				{
					$this->pog_query .= " ".$fcv_array[$i][0]." ";
					continue;
				}
				else
				{
					if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
					{
						$this->pog_query .= " AND ";
					}
					if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
					{
						if ($GLOBALS['configuration']['db_encoding'] == 1)
						{
							$value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
							$this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
						}
						else
						{
							$value =  POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
							$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
						}
					}
					else
					{
						$value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
						$this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
					}
				}
			}
		}
		if ($sortBy != '')
		{
			if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
			{
				if ($GLOBALS['configuration']['db_encoding'] == 1)
				{
					$sortBy = "BASE64_DECODE($sortBy) ";
				}
				else
				{
					$sortBy = "$sortBy ";
				}
			}
			else
			{
				$sortBy = "$sortBy ";
			}
		}
		else
		{
			$sortBy = "questpageid";
		}
		$this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
		$thisObjectName = get_class($this);
		$cursor = Database::Reader($this->pog_query, $connection);
		while ($row = Database::Read($cursor))
		{
			$questpage = new $thisObjectName();
			$questpage->questpageId = $row['questpageid'];
			$questpage->level = $this->Unescape($row['level']);
			$questpage->race = $this->Unescape($row['race']);
			$questpage->npc = $this->Unescape($row['npc']);
			$questpage->island = $this->Unescape($row['island']);
			$questpage->town = $this->Unescape($row['town']);
			$questpage->area = $this->Unescape($row['area']);
			$questpage->field = $this->Unescape($row['field']);
			$questpage->dung = $this->Unescape($row['dung']);
			$questpage->obj = $this->Unescape($row['obj']);
			$questpage->exp = $this->Unescape($row['exp']);
			$questpage->jp = $this->Unescape($row['jp']);
			$questpage->r = $this->Unescape($row['r']);
			$questpage->p = $this->Unescape($row['p']);
			$questpage->basic = $this->Unescape($row['basic']);
			$questpage->choice = $this->Unescape($row['choice']);
			$questpage->bonus = $this->Unescape($row['bonus']);
			$questpage->prev = $this->Unescape($row['prev']);
			$questpage->next = $this->Unescape($row['next']);
			$questpage->intro = $this->Unescape($row['intro']);
			$questpage->object = $this->Unescape($row['object']);
			$questpage->walk = $this->Unescape($row['walk']);
			$questpage->con = $this->Unescape($row['con']);
			$questpage->misc = $this->Unescape($row['misc']);
			$questpage->levelvalue = $this->Unescape($row['levelvalue']);
			$questpage->expvalue = $this->Unescape($row['expvalue']);
			$questpage->jpvalue = $this->Unescape($row['jpvalue']);
			$questpage->rvalue = $this->Unescape($row['rvalue']);
			$questpage->pvalue = $this->Unescape($row['pvalue']);
			$questpage->name = $this->Unescape($row['name']);
			$questpage->content = $this->Unescape($row['content']);
			$questpage->revid = $this->Unescape($row['revid']);
			$questpageList[] = $questpage;
		}
		return $questpageList;
	}
	
	
	/**
	* Saves the object to the database
	* @return integer $questpageId
	*/
	function Save()
	{
		$connection = Database::Connect();
		$this->pog_query = "select `questpageid` from `questpage` where `questpageid`='".$this->questpageId."' LIMIT 1";
		$rows = Database::Query($this->pog_query, $connection);
		if ($rows > 0)
		{
			$this->pog_query = "update `questpage` set 
			`level`='".$this->Escape($this->level)."', 
			`race`='".$this->Escape($this->race)."', 
			`npc`='".$this->Escape($this->npc)."', 
			`island`='".$this->Escape($this->island)."', 
			`town`='".$this->Escape($this->town)."', 
			`area`='".$this->Escape($this->area)."', 
			`field`='".$this->Escape($this->field)."', 
			`dung`='".$this->Escape($this->dung)."', 
			`obj`='".$this->Escape($this->obj)."', 
			`exp`='".$this->Escape($this->exp)."', 
			`jp`='".$this->Escape($this->jp)."', 
			`r`='".$this->Escape($this->r)."', 
			`p`='".$this->Escape($this->p)."', 
			`basic`='".$this->Escape($this->basic)."', 
			`choice`='".$this->Escape($this->choice)."', 
			`bonus`='".$this->Escape($this->bonus)."', 
			`prev`='".$this->Escape($this->prev)."', 
			`next`='".$this->Escape($this->next)."', 
			`intro`='".$this->Escape($this->intro)."', 
			`object`='".$this->Escape($this->object)."', 
			`walk`='".$this->Escape($this->walk)."', 
			`con`='".$this->Escape($this->con)."', 
			`misc`='".$this->Escape($this->misc)."', 
			`levelvalue`='".$this->Escape($this->levelvalue)."', 
			`expvalue`='".$this->Escape($this->expvalue)."', 
			`jpvalue`='".$this->Escape($this->jpvalue)."', 
			`rvalue`='".$this->Escape($this->rvalue)."', 
			`pvalue`='".$this->Escape($this->pvalue)."', 
			`name`='".$this->Escape($this->name)."', 
			`content`='".$this->Escape($this->content)."', 
			`revid`='".$this->Escape($this->revid)."' where `questpageid`='".$this->questpageId."'";
		}
		else
		{
			$this->pog_query = "insert into `questpage` (`level`, `race`, `npc`, `island`, `town`, `area`, `field`, `dung`, `obj`, `exp`, `jp`, `r`, `p`, `basic`, `choice`, `bonus`, `prev`, `next`, `intro`, `object`, `walk`, `con`, `misc`, `levelvalue`, `expvalue`, `jpvalue`, `rvalue`, `pvalue`, `name`, `content`, `revid` ) values (
			'".$this->Escape($this->level)."', 
			'".$this->Escape($this->race)."', 
			'".$this->Escape($this->npc)."', 
			'".$this->Escape($this->island)."', 
			'".$this->Escape($this->town)."', 
			'".$this->Escape($this->area)."', 
			'".$this->Escape($this->field)."', 
			'".$this->Escape($this->dung)."', 
			'".$this->Escape($this->obj)."', 
			'".$this->Escape($this->exp)."', 
			'".$this->Escape($this->jp)."', 
			'".$this->Escape($this->r)."', 
			'".$this->Escape($this->p)."', 
			'".$this->Escape($this->basic)."', 
			'".$this->Escape($this->choice)."', 
			'".$this->Escape($this->bonus)."', 
			'".$this->Escape($this->prev)."', 
			'".$this->Escape($this->next)."', 
			'".$this->Escape($this->intro)."', 
			'".$this->Escape($this->object)."', 
			'".$this->Escape($this->walk)."', 
			'".$this->Escape($this->con)."', 
			'".$this->Escape($this->misc)."', 
			'".$this->Escape($this->levelvalue)."', 
			'".$this->Escape($this->expvalue)."', 
			'".$this->Escape($this->jpvalue)."', 
			'".$this->Escape($this->rvalue)."', 
			'".$this->Escape($this->pvalue)."', 
			'".$this->Escape($this->name)."', 
			'".$this->Escape($this->content)."', 
			'".$this->Escape($this->revid)."' )";
		}
		$insertId = Database::InsertOrUpdate($this->pog_query, $connection);
		if ($this->questpageId == "")
		{
			$this->questpageId = $insertId;
		}
		return $this->questpageId;
	}
	
	
	/**
	* Clones the object and saves it to the database
	* @return integer $questpageId
	*/
	function SaveNew()
	{
		$this->questpageId = '';
		return $this->Save();
	}
	
	
	/**
	* Deletes the object from the database
	* @return boolean
	*/
	function Delete()
	{
		$connection = Database::Connect();
		$this->pog_query = "delete from `questpage` where `questpageid`='".$this->questpageId."'";
		return Database::NonQuery($this->pog_query, $connection);
	}
	
	
	/**
	* Deletes a list of objects that match given conditions
	* @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 
	* @param bool $deep 
	* @return 
	*/
	function DeleteList($fcv_array)
	{
		if (sizeof($fcv_array) > 0)
		{
			$connection = Database::Connect();
			$pog_query = "delete from `questpage` where ";
			for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
			{
				if (sizeof($fcv_array[$i]) == 1)
				{
					$pog_query .= " ".$fcv_array[$i][0]." ";
					continue;
				}
				else
				{
					if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
					{
						$pog_query .= " AND ";
					}
					if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
					{
						$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
					}
					else
					{
						$pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
					}
				}
			}
			return Database::NonQuery($pog_query, $connection);
		}
	}
}
?>